﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StyleMVVM.DependencyInjection;
using StyleMVVM.Notification.Tile;
using StyleMVVM.Notification.Toast;
using StyleMVVM.ViewModel;
using StyleMVVM.Notification.Badge;

namespace ExampleApp.ViewModels
{
	public class TilesBadgesAndToastsViewModel : BaseViewModel
	{
		private BadgeGlyph? selectedGlyph;
		private string tileText;
		private string toastText;

		public BadgeGlyph? SelectedGlyph
		{
			get { return selectedGlyph; }
			set { SetProperty(ref selectedGlyph, value); }
		}

		public IEnumerable<BadgeGlyph> Glyphs
		{
			get
			{
				return Enum.GetValues(typeof(BadgeGlyph))
					 .Cast<BadgeGlyph>();
			}
		}

		public string ToastText
		{
			get { return toastText; }
			set { SetProperty(ref toastText, value); }
		}

		public string TileText
		{
			get { return tileText; }
			set { SetProperty(ref tileText, value); }
		}

		public void UpdateBadge()
		{
			if (selectedGlyph.HasValue)
			{
				Container.Locate<IBadgeService>().UdpateGlyph(selectedGlyph.Value);
			}
		}

		public void UpdateTileText()
		{
			var tileUpdate = Container.Locate<ITileService>().CreateTileSquareText04();

			tileUpdate.TextField1 = TileText;

			Container.Locate<ITileService>().Update(tileUpdate);
		}

		public void SendToast()
		{
			var toast = Container.Locate<IToastService>().CreateToastText01();

			toast.TextField1 = ToastText;

			Container.Locate<IToastService>().Toast(toast);
		}
	}
}
